import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

import NProgress from 'nprogress' 
import 'nprogress/nprogress.css'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Layout',
    redirect:'/home',
    component: () => import('../views/Layout.vue'),
    children: [
      {
        path: 'home',
        name: 'Home',
        component: () => import('../views/Home.vue'),
        meta:{
          bread:["首页"]
        }
      },
      {
        path: 'count',
        name: 'Count',
        component: () => import('../views/person/Count.vue'),
        meta:{
          bread:["个人中心","账户修改"]
        }
      },
      {
        path: 'user_info',
        name: 'UserInfo',
        component: () => import('../views/person/User_info.vue'),
        meta:{
          bread:["个人中心","个人信息"]
        }
      },
      {
        path: 'grade',
        name: 'Grade',
        component: () => import('../views/managingPeople/Grade.vue'),
        meta:{
          bread:["人员管理","班级管理"]
        }
      },
      {
        path: 'student',
        name: 'Student',
        component: () => import('../views/managingPeople/Student.vue'),
        meta:{
          bread:["人员管理","学生管理"]
        }
      },
      {
        path: 'leave_school',
        name: 'LeaveSchool',
        component: () => import('../views/managingPeople/LeaveSchool.vue'),
        meta:{
          bread:["人员管理","离校登记"]
        }
      },
      {
        path: 'enviroument',
        name: 'Enviroument',
        component: () => import('../views/room/Enviroument.vue'),
        meta:{
          bread:["楼宇管理","卫生管理"]
        }
      },
      {
        path: 'repair',
        name: 'Repair',
        component: () => import('../views/room/Repair.vue'),
        meta:{
          bread:["楼宇管理","维修管理"]
        }
      },
      {
        path: 'room_list',
        name: 'RoomList',
        component: () => import('../views/room/RoomList.vue'),
        meta:{
          bread:["楼宇管理","宿舍列表"]
        }
      },
      {
        path: 'visitor',
        name: 'Visitor',
        component: () => import('../views/room/Visitor.vue'),
        meta:{
          bread:["楼宇管理","访客管理"]
        }
      },
      {
        path: 'discipline',
        name: 'Discipline',
        component: () => import('../views/Discipline.vue'),
        meta:{
          bread:["违纪管理"]
        }
      },
      {
        path: 'money',
        name: 'Money',
        component: () => import('../views/Money.vue'),
        meta:{
          bread:["费用管理"]
        }
      },
    ]
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('../views/Login.vue')
  },
  {
    path: "*",
    // redirect: '/404',
    component: () => import("@/views/404"),
    
},
  
]

const router = new VueRouter({
  routes
})

//当路由开始跳转时
router.beforeEach((to, from , next) => {
  // 开启进度条
  NProgress.start();
  // 这个一定要加，没有next()页面不会跳转的。这部分还不清楚的去翻一下官网就明白了
  next();
});
//当路由跳转结束后
router.afterEach(() => {  
  // 关闭进度条
  NProgress.done()
})
export default router
